<?php
	require ('host_config.php');
	//常數宣告
	define('DS', DIRECTORY_SEPARATOR);
	define('APP_DIR',dirname(__FILE__));	
	define('Models_DIR', APP_DIR.DS.'Model'.DS);
	define('Controllers_DIR', APP_DIR.DS.'Controller'.DS);
	define('Views_DIR', APP_DIR.DS.'views'.DS);	
	define('IMG_DIR', $web_img);
	define('CSS_DIR', $web_css);	
	define('LIB_DIR', $web_lib);
	require(APP_DIR .DS.'Controller'.DS.'Controller.php'); 
	require(APP_DIR .DS.'Model'.DS.'MySQL.php'); 
	//宣告Libraries
	$_control = new Controller();
	//網址分析
	$_URL=$_SERVER['REQUEST_URI'];
	$_REDIRECT_URL = explode("/",$_URL);
	$t_REDIRECT_URL= explode(".", $_REDIRECT_URL[1]);
	$_REDIRECT_URL[1]=$t_REDIRECT_URL[0];
	//分析get
	$N_REDIRECT_URL = explode("?", $_REDIRECT_URL[1]);
	switch ($N_REDIRECT_URL[0]) {
		//將需要的page加在這個下面
		case "forphone":
			return require Controllers_DIR."forPhoneController.php";
		case "index":
		case "modifyForm":
		case "orderinfo":
		case "register":
		case "logout":
			return require Views_DIR.$_REDIRECT_URL[1].'.php';
		//for user
		case "user":
			return require Controllers_DIR."user_controller.php";
		//Page Controller
		case "page":
			return require Controllers_DIR."page_controller.php";
		//首頁
		default:
			$_control->view('login');
			break;
	}
?>